import 'dart:io';
import 'dart:typed_data';

extension Extra on File {
  String get name => this.path.split("/").last;

  bool get isPhoto =>
      name.endsWith(".jpg") || name.endsWith(".png") || name.endsWith(".jpeg");

  Uint8List get binary {
    // 如果不打开，二进制会包含文件名和后缀，可能会导致错误
    final inner = openSync();
    final length = inner.lengthSync();
    return inner.readSync(length);
  }
}
